<{include file="Toy/toy_top.html"}>
    </head>
    <body>
    	<div id="wrap" class="apply">
			<{include file="Toy/toy_nav.html"}>
    		
    		<div class="container">
    			<div class="toy-list">
    				<ul>
						<{include file="Toy/apply_list.html"}>
    				</ul>
    			</div>
    		</div>
    		
    		<div class="bottom">
    			<a href="javascript:void(0);" class="sure" onclick="submit()">确　定</a>
    			<p>(选择您要交换的玩具)</p>
    		</div>
    	</div>
    	<script src="<{$preStaticUrl}>Wap/toy/js/zepto.min.js"></script>
    	<script src="<{$preStaticUrl}>Wap/toy/js/index.js"></script>
    	<script>
			var slave=0;
			var main='<{$mainItemId}>';
    		$(function(){
				init_mu_timer();
    			$(".toy-list a").click(function(){
					$obj=$(this).toggleClass("selected");
					$('.selected').not(	$obj).removeClass('selected');
					slave=$obj.attr('id');
    			})
    		})


			function submit(){
				$.post("<{u('applyDo')}>",{main:main,slave:slave},function(re){
					if(re.status==0){
						tip('申请成功',function(){location.href="<{u('deal')}>"});
					}else{
						tip(re.msg);
					}
				},'json');
			}

			var muhandle =null;
			function init_mu_timer(){ //递减 class = mutimer 的元素
				if(muhandle != null)	clearInterval(muhandle);
				muhandle = setInterval("refresh_mu_timer()",999);
			}
			//时间递减队列
			function refresh_mu_timer(){
				var obj	= $(".mutimer");
				var l	= obj.size();
				if(l>0){
					for(var i=0;i<l;i++){
						var _that = obj[i];
						time = $(_that).attr('data-time');
						time	= time-1;
						obj[i].innerHTML =print_time(time);
						$(obj[i]).attr('data-time', time);
					}
				}else{
					clearInterval(muhandle);
				}
			}

			function print_time(time){
				if(time<= 0)	return "00:00:00";
				var h	= parseInt(time/3600);
				var d   = parseInt(h/24);
				if(d>=1){
					return d+'天'+(h%24)+'小时';
				}
				var m	= parseInt((time-h*3600)/60);
				var	s	= parseInt(time-h*3600-m*60);
				if(h<10)	h='0'+h;
				if(m<10)	m='0'+m;
				if(s<10)	s='0'+s;
				return h+":"+m+":"+s;
			}
    	</script>
	</body>
</html>
